package com.bjpowernode.controller.advice;
import com.bjpowernode.dto.ResultDTO;
import com.bjpowernode.exception.CRUDException;
import com.bjpowernode.exception.LoginException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
@RestControllerAdvice
public class MyControllerAdvice {
    @ExceptionHandler(LoginException.class)
    public ResultDTO login(LoginException e){
        ResultDTO resultDTO=new ResultDTO();
        resultDTO.setResult(ResultDTO.ERROR);
        resultDTO.setMess(e.getMessage());
        return resultDTO;
    }

    @ExceptionHandler(CRUDException.class)
    public ResultDTO crud(CRUDException e){
        ResultDTO resultDTO=new ResultDTO();
        resultDTO.setResult(ResultDTO.ERROR);
        resultDTO.setMess(e.getMessage());
        return resultDTO;
    }
}
